var t = getApp(), a = require("../../../utils/themeSkin/skinBehavior");

Page({
    behaviors: [ a ],
    data: {
        balanceLang: "生态积分",
        statusValue: 0,
        selectShow: !1,
        selectType: 0,
        record_list: [],
        serviceTypeList: [],
        selectTapInd: 0,
        isLoadMore: !0,
        page: 1,
        total_page: 0
    },
    onLoad: function(t) {
        this.getData();
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {
        this.data.page >= this.data.total_page || this.getMoreData();
    },
    onShareAppMessage: function() {},
    getMoreData: function() {
        var a = this;
        if (this.data.isLoadMore && (this.data.isLoadMore = !1, !(this.data.page >= this.data.total_page))) {
            this.setData({
                page: this.data.page + 1
            });
            var e = t.getNetAddresss("plugin.ecological-point.frontend.modules.point.controllers.records.index");
            t._postNetWork({
                url: e,
                data: {
                    page: this.data.page,
                    source_id: this.data.selectType,
                    change_type: this.data.statusValue
                },
                success: function(t) {
                    var e = t.data;
                    if (1 == e.result) {
                        a.data.isLoadMore = !0;
                        var o = e.data.page_list.data;
                        a.data.record_list = a.data.record_list.concat(o), a.setData({
                            record_list: a.data.record_list
                        });
                    } else wx.showToast({
                        icon: "none",
                        title: e.msg,
                        duration: 1e3
                    });
                },
                fail: function(t) {
                    console.log(t);
                }
            });
        }
    },
    selectShowTap: function() {
        this.setData({
            selectShow: !this.data.selectShow
        });
    },
    selectStatus: function(t) {
        console.log(t), this.init(), this.setData({
            statusValue: t.currentTarget.dataset.key
        }), this.getData();
    },
    selectTap: function(t) {
        var a = t.currentTarget.dataset.ind;
        this.setData({
            selectType: a,
            selectTapInd: a,
            selectShow: !1
        }), this.init(), this.getData();
    },
    init: function() {
        this.setData({
            isLoadMore: !0,
            page: 1,
            total_page: 0,
            record_list: []
        });
    },
    getData: function() {
        var a = this, e = t.getNetAddresss("plugin.ecological-point.frontend.modules.point.controllers.records.index");
        t._postNetWork({
            url: e,
            data: {
                page: this.data.page,
                source_id: this.data.selectType,
                change_type: this.data.statusValue
            },
            success: function(t) {
                var e = t.data;
                if (1 == e.result) {
                    var o = wx.getStorageSync("yz_basic_info");
                    wx.setNavigationBarTitle({
                        title: o.ecological_point ? "".concat(o.ecological_point, "明细") : "生态积分明细"
                    }), a.data.serviceTypeList = e.data.source_comment, a.data.serviceTypeList[0] = "业务类型", 
                    a.setData({
                        record_list: e.data.page_list.data,
                        source_comment: e.data.source_comment,
                        isLoadMore: !0,
                        total_page: e.data.page_list.last_page,
                        serviceTypeList: a.data.serviceTypeList
                    }), wx.setNavigationBarColor({
                        frontColor: "#ffffff",
                        backgroundColor: a.data.themeBaseColor,
                        animation: {
                            duration: 400,
                            timingFunc: "easeIn"
                        }
                    }), a.data.total_page || (a.data.total_page = 0);
                } else wx.showToast({
                    icon: "none",
                    title: e.msg,
                    duration: 1e3
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    }
});